package com.leviassaf.androidbasics;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.app.Activity;

//8
public class StartingPoint extends Activity {

	int intCounter;
	Button btnAdd, btnSubtract;
	TextView txtDisplay;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		intCounter = 0;
		btnAdd = (Button)findViewById(R.id.btnAdd);
		btnSubtract = (Button)findViewById(R.id.btnSubtract);
		txtDisplay = (TextView)findViewById(R.id.txtDisplay);
		//9-10
		btnAdd.setOnClickListener(new View.OnClickListener() {
			
			public void onClick(View v) {
				// TODO Auto-generated method stub
				intCounter++;
				txtDisplay.setText(String.format("Your total is: %s", intCounter));
			}
		});

		btnSubtract.setOnClickListener(new View.OnClickListener() {
			
			public void onClick(View v) {
				// TODO Auto-generated method stub
				intCounter--;
				txtDisplay.setText(String.format("Your total is: %s", intCounter));
			}
		});

		this.setTitle(String.format("%s-%s", this.getTitle().toString(), this.getClass().getSimpleName()));
	}
}
